<template>
    <div class="wrapper tocash">
        <mt-header title="提现" class="no-bg">
            <mt-button icon="back" slot="left" @click="$router.back(-1)"></mt-button>
        </mt-header>
        <div class="blank-9"></div>
        <div class="list">
            <div style="padding:10px 0;">验证账号</div>
            <countdown @sendValueToParent="getValueFromChild"  mobile="none"></countdown>
        </div>
        <div class="blank-9"></div>
        <div class="list">
            <inputPayPwd title="支付密码" @sendValueToParent="getPayPwdFromChild"></inputPayPwd>
        </div>
        <div class="missPsd-btn" @click="$router.push('/account/setting/editPayPwd/findPayPwd')">忘记密码</div>
        <div class="blank-9"></div>
        <div class="default-btn">
            <mt-button type="primary" size="large" :disabled="(inputValueCode && realInput.length==6)?false:true" @click.native="toCash">确定</mt-button>
        </div>
    </div>
</template>

<script>
import countdown from "@/components/Countdown"
import inputPayPwd from "@/components/InputPayPwd"
import { PostExtract } from '@/api/api'
import { mapGetters } from 'vuex'
export default {
    data: function () {
        return {
            realInput:'',
            inputValueCode:''
        }
    },
    components:{
        countdown,
        inputPayPwd
    },
    methods: {
        getPayPwdFromChild(value){
            this.realInput = value;
        },
        getValueFromChild(value){
            this.inputValueCode = value;
        },
        toCash(){
            PostExtract({
                extractAddress:this.$route.query.extractAddress,
                extractCount:this.$route.query.extractCount,
                validationCode:this.inputValueCode,
                payPassword:this.realInput
            }).then(res => {
                if( res.code == 200 ){
                    //提现成功
                    this.$router.push({
                        name : 'cashres',
                        query:{ 
                            isSuccess : true,
                            res : res.msg
                        }
                    })
                }else{
                    this.$router.push({
                        name : 'cashres',
                        query:{ 
                            isSuccess : false,
                            res : res.msg
                        }
                    })
                }
            })
        }
    }
}
</script>

<style lang="stylus" scoped>
.wrapper{
    // color:#666;
    .missPsd-btn{
        display:block;
        text-align right;
        color: rgba(0,78,162,1);
        font-size: 12px;
        margin-bottom: 15px;
        margin-right: 37px;
    }
}  
</style>